﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UtilZ.Dotnet.Ex.Model
{
    /// <summary>
    /// 泛型键值类
    /// </summary>
    [Serializable]
    public class TKeyTValue<TKey, TValue> : NotifyPropertyChangedAbs
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public TKeyTValue()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        public TKeyTValue(TKey key, TValue value)
        {
            this._key = key;
            this._value = value;
        }

        private TKey _key = default(TKey);
        /// <summary>
        /// 获取或设置键
        /// </summary>
        public TKey Key
        {
            get { return _key; }
            set
            {
                _key = value;
                base.OnRaisePropertyChanged();
            }
        }

        private TValue _value = default(TValue);
        /// <summary>
        /// 获取或设置值
        /// </summary>
        public TValue Value
        {
            get { return _value; }
            set
            {
                _value = value;
                base.OnRaisePropertyChanged();
            }
        }


        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return $"Key:{this._key}    Value:{this._value}";
        }
    }
}
